<?php
class MisInfosTest extends PHPUnit_Framework_TestCase  
{  

    public $rel;
	public function setUp()
    {
        $this->rel = array(
           'type'      => 'episode',
           'mis_id'    => '1',
           'mis_eid'   => '1',
           'mis_pid'   => '0',
           'pdes_id'   => '0',
           'pdes_eid'  => '45',
           'pdes_pid'  => '0'
        );
       
	}
	public function tearDown()
	{
	} 

	public function testAddress()  
    {  
        $eids = array();
        $xml = '<?xml version="1.0" encoding="utf-8"?>
                   <iAddress EPISCENE_ID="2658" START_SEQ="1" NUM="10">
                   <ADDRESS_ID INFOLINK_ID="1375">131</ADDRESS_ID>
                   <ADDRESS_ID INFOLINK_ID="1376">134</ADDRESS_ID>
                   <ADDRESS_ID INFOLINK_ID="1377">136</ADDRESS_ID>
                </iAddress>';
        $xml_obj = simplexml_load_string($xml);
        foreach($xml_obj->ADDRESS_ID as $p){
            $eids[] = (string)$p;
        }

        $address = new MisInfoAddress($this->rel);
        $rs = $address->import($eids);

		$this->assertEquals(true, $rs);
	}

	public function testAward()  
    {  
        $eids = array();
        $xml = '<?xml version="1.0" encoding="utf-8"?>
                <iAwards EPISCENE_ID="2658" START_SEQ="1" NUM="10">
                    <AWARD_ID INFOLINK_ID="1381">23</AWARD_ID>
                    <AWARD_ID INFOLINK_ID="1380">25</AWARD_ID>
                    <AWARD_ID INFOLINK_ID="1378">52</AWARD_ID>
                    <AWARD_ID INFOLINK_ID="1379">53</AWARD_ID>
                </iAwards>';
        $xml_obj = simplexml_load_string($xml);
        foreach($xml_obj->AWARD_ID as $p){
            $eids[] = (string)$p;
        }

        $address = new MisInfoAward($this->rel);
        $rs = $address->import($eids);

		$this->assertEquals(true, $rs);
	}

    public function testBiography()  
    {  
        $eids = array();
        $xml = '<?xml version="1.0" encoding="utf-8"?>
                <iBiography EPISCENE_ID="2658" START_SEQ="1" NUM_OF_PROG="10">
                    <BIOGRAPHY_ID INFOLINK_ID="999">139</BIOGRAPHY_ID>
                </iBiography>';
        $xml_obj = simplexml_load_string($xml);
        foreach($xml_obj->BIOGRAPHY_ID as $p){
            $eids[] = (string)$p;
        }

        $address = new MisInfoBiography($this->rel);
        $rs = $address->import($eids);

		$this->assertEquals(true, $rs);
	}

    public function testGeneralInfo()  
    {  
        $eids = array();
        $xml = '<?xml version="1.0" encoding="utf-8"?>
                <iGeneral_info EPISCENE_ID="2657" START_SEQ="1" NUM="10">
                   <GENERAL_ID INFOLINK_ID="1369">69</GENERAL_ID>
                </iGeneral_info>';
        $xml_obj = simplexml_load_string($xml);
        foreach($xml_obj->GENERAL_ID as $p){
            $eids[] = (string)$p;
        }

        $address = new MisInfoGeneralInfo($this->rel);
        $rs = $address->import($eids);

        $this->assertEquals(true, $rs);
	}
}
